package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级",description = "护理等级相关接口")
public class NursingLevelController extends BaseController{


    @Autowired
    private NursingLevelService nursingLevelService;

    /**
     * 查询所有护理等级
     */
    @GetMapping("/listAll")
    @ApiOperation(value = "查询所有护理等级",notes = "返回所有护理等级信息")
    public ResponseResult<List<NursingLevelVo>> selectAll(){
        return success(nursingLevelService.selectAll());
    }


    /**
     * 新增护理等级
     */
   @ApiOperation(value = "新增护理等级",notes = "返回新增护理等级信息")
    @PostMapping("/insert")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelDto nursingLevelDto){

       return toAjax(nursingLevelService.addNursingLevel(nursingLevelDto));
   }


    /**
     * 条件分页查询
     */
    @ApiOperation(value = "条件分页查询",notes = "返回条件分页查询结果")
    @GetMapping("/listByPage")
    public ResponseResult<PageResponse<NursingLevelVo>> selectByPage(
            @ApiParam(value = "页码",required = true) Integer pageNum,
            @ApiParam(value = "每页显示的记录数，用于控制每页包含的护理等级数量",required = true) Integer pageSize,
            @ApiParam(value = "护理计划名称") String name,
            @ApiParam(value = "护理计划状态") Integer status){

        return success(nursingLevelService.selectByPage(pageNum,pageSize,name,status));
    }


    /**
     * 根据id查询
     *
     */
    @ApiOperation(value = "根据id查询护理等级信息",notes = "传入护理等级id，返回护理等级信息")
    @GetMapping("/{id}")
    public ResponseResult<NursingLevelVo> selectById(@PathVariable Long id){
        return success(nursingLevelService.selectById(id));
    }


    /**
     * 修改护理等级
     */
    @ApiOperation(value = "修改护理等级",notes = "传入护理等级信息，返回修改结果")
    @PutMapping("/update")
    public ResponseResult updateNursingLevel(@RequestBody NursingLevelDto nursingLevelDto){
        return toAjax(nursingLevelService.updateNursingLevel(nursingLevelDto));
    }


    /**
     * 根据id删除等级
     */
    @ApiOperation(value = "根据id删除护理等级",notes = "传入护理等级id，返回删除结果")
    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteById(@PathVariable Long id){
        return toAjax(nursingLevelService.deleteById(id));
    }


    /**
     * 启用禁用
     */

    @ApiOperation(value = "启用禁用",notes = "传入护理等级id，返回启用禁用结果")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult updateNursingLevelStatus(@PathVariable Long id,@PathVariable Integer status){
        return toAjax(nursingLevelService.updateNursingLevelStatus(id,status));
    }


}
